package Io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class Practice2 {
    public static void main(String[] args) throws IOException {
        File file=new File("Pra.txt");
       FileOutputStream fos=new FileOutputStream(file);
       fos.write(256);
       fos.write(254);
        System.out.println("finish");
       fos.close();



        /*
        FileInputStream fis=new FileInputStream("Pra.txt");
        int a=fis.read();
         System.out.println(a);
        a=fis.read();
         System.out.println(a);
        fis.close();





       /*
        FileInputStream fis=new FileInputStream("aaaa.jpg");
        FileOutputStream fos=new FileOutputStream("aaaa_practice.jpg");
        int a;
        while ((a=fis.read())!=-1){
            fos.write(a); }
         fis.close();
         fos.close();
         System.out.println("finish");





       /*
        FileInputStream fis=new FileInputStream("aaaa.jpg");
        FileOutputStream fos=new FileOutputStream("aaaa_practice2.jpg");
        int len;
        long start=System.currentTimeMillis();
        byte[] data=new byte[3];
        while ((len=fis.read(data))!=-1){
            fos.write(data,0,len);
        }
        long end=System.currentTimeMillis();
         fis.close();
         fos.close();
         System.out.println("finish");
         System.out.println((end-start));





        /*
        File file=new File("Pra2.txt");
        FileOutputStream fos=new FileOutputStream(file,true);
        String data="钱钱钱钱钱";
        byte[] str=data.getBytes(StandardCharsets.UTF_8);
        fos.write(str);
        fos.write("爱爱爱爱".getBytes(StandardCharsets.UTF_8));
         System.out.println("finish");
         fos.close();








        /* File file=new File("pra2.txt");
        FileInputStream fis=new FileInputStream(file);
        byte[] data=new byte[(int) file.length()];
        fis.read(data);
        String A=new String(data, StandardCharsets.UTF_8);
         System.out.println(A);
         fis.close();


        */


    }
}
